package  
{
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.ProgressEvent;
	import flash.net.URLRequest;
	import flash.net.URLRequestHeader;
	import flash.net.URLStream;
	
	/**
	 * ...
	 * @author hbb
	 */
	public class URLStreamTest extends Sprite 
	{
		
		public function URLStreamTest() 
		{
			testProgressData();
		}
		
		private function testProgressData():void
		{
			// "Range" only avariable in AIR application sandbox
			// that means unless installed-time swf can use it.
			
			var req:URLRequest = new URLRequest('http://download.taobaocdn.com/wangwang/AliIM2010_taobao(6.50.12C).exe');
			//req.requestHeaders.push( new URLRequestHeader('Range', 'bytes=' + 9999 + '-' + 17838208) );
			
			var ldr:URLStream = new URLStream;
			ldr.addEventListener(Event.OPEN, open);
			ldr.addEventListener(ProgressEvent.PROGRESS, progress);
			ldr.addEventListener(Event.COMPLETE, complete);
			ldr.load( req );
			
			function progress(e:ProgressEvent):void
			{
				trace(e);
				trace('length:', ldr.bytesAvailable);
			}
			function complete(e:Event):void
			{
				trace(e);
			}
			function open(e:Event):void
			{
				trace(e);
			}
		}
		
	}

}